package thread;

class MyThread extends Thread{
    @Override
    public void run() {
        while (true) {
            System.out.println("hello world");
            try {
                //不能throws
                //此处是方法重写,对于父类的run方法来说,没有throws xxx异常这样的说法
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}


public class demo1 {
    public static void main(String[] args) {
        MyThread myThread = new MyThread();
        myThread.run();

        while(true){
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
